#%%
# Most applications and modules use both unittest and doctest, at the same time.
    # myproject
    # test
    # doc
    
# global abstract class
import types
import unittest

class TestAccess( unittest.TestCase ):
    def test_should_add_and_get_attribute( self ):
        self.__dict__.update({"Flag": True})
        # self.object.new_attribute = True
        self.assertTrue ( self.__dict__["Flag"] )
    
    def test_should_fail_on_missing(self):
        self.assertRaises(AttributeError, lambda: self.object.undefined )

#  3 concrete TestAccess child classes
class SomeClass:
    pass

class Test_EmptyClass(TestAccess):
    def setUp(self):
        self.object = SomeClass()
        
class Test_Namespace (TestAccess):
    def setUp(self):
        self.object = types.SimpleNamespace()
        
class Test_Object(TestAccess):
    def setUP(self):
        self.object = object()
        
        
# create a component to run testings and prevent to run TestAccess abstract class
def suite():
    s= unittest.TestSuite()
    s.addTests(
    unittest.defaultTestLoader.loadTestsFromTestCase(Test_EmptyClass) )
    s.addTests(
    unittest.defaultTestLoader.loadTestsFromTestCase(Test_Namespace) )
    s.addTests(
    unittest.defaultTestLoader.loadTestsFromTestCase(Test_Object) )
    return s
if __name__ == "__main__":
    t= unittest.TextTestRunner()
    t.run( suite() )
# %%
# Docstring
## ReStructured Text (RST)
## docstrings

def factorial(n):
    """Compute n! reucrsively.

    Args:
        n (int): an integer >= 0
    returns:
        n!
    
    Because of Python's stack limitation, this won't
    compute a value larger than about 1000!.
    
    >>> factorial(5)
    120
    """
    if n == 0: return 1
    return n * factorial(n - 1)

# %%
factorial(3)
# %%
